<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:pe="http://primefaces.org/ui/extensions">

    <ui:define name="content">
        <h:outputStylesheet library="css" name="printing.css"></h:outputStylesheet>
        <h:form>
            <p:panel header="Daily Inward Fee Summery">

                <h:panelGrid columns="3" >

                    <h:outputLabel value="From Date"/>
                    <p:spacer width="10" height="1" ></p:spacer>
                    <p:calendar value="#{pharmacySaleReport.fromDate}" navigator="true" pattern="dd MMMM yyyy "  >
                    </p:calendar>

                    <h:outputLabel value="To Date"/>
                    <p:spacer width="10" height="1" ></p:spacer>
                    <p:calendar value="#{pharmacySaleReport.toDate}" navigator="true" pattern="dd MMMM yyyy " >
                    </p:calendar>

                    <h:outputLabel value="Instituion"/>
                    <p:spacer width="10" height="1" ></p:spacer>
                    <p:autoComplete styleClass="noPrintButton mediuminput"  
                                    value="#{pharmacySaleReport.institution}"  
                                    style="text-align: left; "  completeMethod="#{institutionController.completeCompany}" var="dept" itemValue="#{dept}" itemLabel="#{dept.name}" forceSelection="true" rendered="true" requiredMessage="You must select Institution" >
                    </p:autoComplete>

                    <h:outputLabel value="Departmant"/>
                    <p:spacer width="10" height="1" ></p:spacer>
                    <p:autoComplete styleClass="noPrintButton mediuminput" 
                                    value="#{pharmacySaleReport.department}"  
                                    style="text-align: left;"  completeMethod="#{departmentController.completeDept}" var="dep" itemValue="#{dep}" itemLabel="#{dep.name}" forceSelection="true" rendered="true" requiredMessage="You must select a department" >
                    </p:autoComplete>

                </h:panelGrid>

                <h:panelGrid columns="3">
                    <p:commandButton ajax="false" value="Process" 
                                    action="#{pharmacySaleReport.createDailyInwardFeeSummeryWithoutCounts}"/>
                    <p:commandButton ajax="false" value="Excel" 
                                     styleClass="noPrintButton" style="float: right;" >
                        <pe:exporter type="xlsx" target="sum1" fileName="report_pharmacy_sale_by_date_summery"  />
                    </p:commandButton>
                    <p:commandButton ajax="false" value="Print" styleClass="noPrintButton" >
                        <p:printer target="panelPrint" />
                    </p:commandButton>
                </h:panelGrid>

                <p:panel id="panelPrint" styleClass="noBorder summeryBorder">
                    <p:dataTable id="sum1" value="#{pharmacySaleReport.billedSummery.bills}" var="i"
                        rows="20"
                        paginator="true"
                        paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                        rowsPerPageTemplate="20, 50, 100" 
                        >   
                        <f:facet name="header" >
                            <p:outputLabel value="Daily Inward Fee Summery" />
                        </f:facet>
                        <p:columnGroup type="header">
                            <p:row >
                                <p:column colspan="5" >
                                    <f:facet name="header" >
                                        <p:outputLabel value="Institution - #{pharmacySaleReport.institution.name}" rendered="#{pharmacySaleReport.institution ne null}" />
                                        <p:outputLabel value="Department - #{pharmacySaleReport.department.name}" rendered="#{pharmacySaleReport.department ne null}" />
                                    </f:facet>
                                </p:column>
                            </p:row>
                            <p:row >
                                <p:column colspan="5" >
                                    <f:facet name="header" >
                                        <h:outputLabel value="From : "/>
                                        <h:outputLabel value="#{pharmacySaleReport.fromDate}">
                                            <f:convertDateTime pattern="dd MMMM yyyy HH:mm:ss a"/>
                                        </h:outputLabel>
                                    </f:facet>

                                </p:column>
                            </p:row>
                            <p:row >
                                <p:column colspan="5" >
                                    <f:facet name="header" >
                                        <h:outputLabel value="To :"/>
                                        <h:outputLabel value="#{pharmacySaleReport.toDate}">
                                            <f:convertDateTime pattern="dd MMMM yyyy HH:mm:ss a"/>
                                        </h:outputLabel>
                                    </f:facet>

                                </p:column>
                            </p:row>
                            <p:row>
                                <p:column headerText="Date" ></p:column>
                                <p:column headerText="Hospital Fee" ></p:column>
                                <p:column headerText="Reagent Fee" ></p:column>
                                <p:column headerText="Professional Fee" ></p:column>
                                <p:column headerText="Net Value" ></p:column>
                            </p:row>

                        </p:columnGroup>

                        <p:column headerText="Date" >
                            <f:facet name="header">
                                <h:outputLabel value="Date" />
                            </f:facet>
                            <h:outputLabel value="#{i.string}" />
                        </p:column>
                        <p:column headerText="Hospital Fee" styleClass="averageNumericColumn">
                            <f:facet name="header">
                                <h:outputLabel value="Hospital Fee" />
                            </f:facet>
                            <h:outputLabel value="#{i.value1}">
                                <f:convertNumber pattern="#,##0.00" />
                            </h:outputLabel>
                        </p:column>
                        <p:column headerText="Regent Fee" styleClass="averageNumericColumn">
                            <f:facet name="header">
                                <h:outputLabel value="Regent Fee" />
                            </f:facet>
                            <h:outputLabel value="#{i.value2}">
                                <f:convertNumber pattern="#,##0.00" />
                            </h:outputLabel>
                        </p:column>
                        <p:column headerText="Professional Fee" styleClass="averageNumericColumn">
                            <f:facet name="header">
                                <h:outputLabel value="Professional Fee" />
                            </f:facet>
                            <h:outputLabel value="#{i.value3}">
                                <f:convertNumber pattern="#,##0.00" />
                            </h:outputLabel>
                        </p:column>
                        <p:column headerText="Net Value" styleClass="averageNumericColumn">
                            <f:facet name="header">
                                <h:outputLabel value="Net Value" />
                            </f:facet>
                            <h:outputLabel value="#{i.value1+i.value2+i.value3}">
                                <f:convertNumber pattern="#,##0.00" />
                            </h:outputLabel>
                        </p:column>


                        <p:columnGroup type="footer">
                            <p:row>
                                <p:column footerText="Total  "/>
                                <p:column footerText="#{pharmacySaleReport.billedSummery.billedTotal}" style="text-align: right;">
                                    <f:facet name="footer" >
                                        <h:outputLabel value="#{pharmacySaleReport.billedSummery.billedTotal}">
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>
                                <p:column footerText="#{pharmacySaleReport.billedSummery.refundedTotal}" style="text-align: right;">
                                    <f:facet name="footer" >
                                        <h:outputLabel value="#{pharmacySaleReport.billedSummery.refundedTotal}">
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>
                                <p:column footerText="#{pharmacySaleReport.billedSummery.cancelledTotal}" style="text-align: right;">
                                    <f:facet name="footer" >
                                        <h:outputLabel value="#{pharmacySaleReport.billedSummery.cancelledTotal}">
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>

                                <p:column footerText="#{pharmacySaleReport.billedSummery.billedTotal+pharmacySaleReport.billedSummery.cancelledTotal+pharmacySaleReport.billedSummery.refundedTotal}" style="text-align: right;">
                                    <f:facet name="footer" >
                                        <h:outputLabel value="#{pharmacySaleReport.billedSummery.billedTotal+pharmacySaleReport.billedSummery.cancelledTotal+pharmacySaleReport.billedSummery.refundedTotal}">
                                            <f:convertNumber pattern="#,##0.00" />
                                        </h:outputLabel>
                                    </f:facet>
                                </p:column>

                            </p:row>
                        </p:columnGroup>

                        </p:dataTable>
                    <p:spacer height="30px"/>
                </p:panel>                    
            </p:panel>


        </h:form>

    </ui:define>



</ui:composition>
